/**
 * setter,getter関数を使ったプロパティをTweenerで動かすためのSpecialPropertyのテスト
 * to compile : haxe -cp test -cp libs -swf-version 9 -swf twSpecialProperty.swf -main TWSpecialProperty
 *
 * 2009/03 IT Planning.
 */
import flash.display.Sprite;
import caurina.transitions.Tweener;

class TWSpecialProperty
{
	static function main()
	{
		var c = new MyComponent();
		c.addStage();

		var _valueX_get = function(p_obj:MyComponent, params, extra) return p_obj.getMyX();

		var _valueX_set = function(p_obj:MyComponent, p_value, params, extral)
			p_obj.setMyX(p_value);

		Tweener.registerSpecialProperty("_valueX", _valueX_get, _valueX_set, []);
		Tweener.addTween(c, { time:5, _valueX:100 });
	}
}

class MyComponent
{
	private var _body : Sprite;
	public var myx( getMyX, setMyX ) : Float;

	public function new ()
	{
		_body = new Sprite();
		_body.graphics.beginFill(0xFF0000);
		_body.graphics.drawCircle(50,50,50);
		_body.graphics.endFill();
	}

	public function getMyX ()
	{
		return _body.x;
	}
	public function setMyX(new_x)
	{
		return _body.x = new_x;
	}

	public function addStage() {
		flash.Lib.current.addChild(_body);
	}
}